package com.glorysoft.tonglingxjpda.ui.home.view

import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Toast
import com.glorysoft.tonglingxjpda.BR
import com.glorysoft.tonglingxjpda.R
import com.glorysoft.tonglingxjpda.base.BaseActivity
import com.glorysoft.tonglingxjpda.base.MyApp
import com.glorysoft.tonglingxjpda.databinding.ActivityHomeBinding
import com.glorysoft.tonglingxjpda.ui.home.viewmodel.HomeViewModel
import com.glorysoft.tonglingxjpda.ui.setting.view.SettingActivity
import com.pda.platform.ui.ui_pdaplatform.entity.FreeUI_TabIndexGridEntity
import jcifs.UniAddress
import jcifs.smb.NtlmPasswordAuthentication
import jcifs.smb.SmbSession
import kotlinx.android.synthetic.main.activity_home.*

/**
 * FileName: HomeActivity
 * Author: XJH
 * Date: 2021/7/12 17:19
 * Description:
 * History:
 */
class HomeActivity : BaseActivity<HomeViewModel, ActivityHomeBinding>() {
    override fun layoutId(): Int {
        return R.layout.activity_home
    }

    override fun initVariableId(): Int {
        return BR.mainViewModel
    }

    override fun initView(savedInstanceState: Bundle?) {
        viewModel.initAssets(this)
        viewModel.defUI.callObserve.observe(this){
            when(it.type){
                viewModel.START_ACTIVITY -> {
                    val intent = Intent()
                    val entity = it.item as FreeUI_TabIndexGridEntity
                    try {
                        val clazz = Class.forName(entity.skipClass)
                        intent.putExtra("showPlugin", entity.showPlugin)
                        intent.setClass(this, clazz)
                    } catch (var4: Exception) {
                        var4.printStackTrace()
                    }
                    startActivity(intent)
                }
                viewModel.MFGLAYOUT -> llMFGLayout.visibility = View.GONE
            }
        }
    }

    override fun initData() {
        ivSetting.setOnClickListener{
            startActivity(SettingActivity::class.java)
        }

    }
}